<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<script>
	function goInsert() {
		var form = document.getElementById("form");
		form.action = '/${domainVariable}/insert.html';
		form.submit();
	}
	function goUpdate() {
		var form = document.getElementById("form");
		form.action = '/${domainVariable}/update.html';
		form.submit();
	}
</script>
<form id="form" name="form" method="post">
<c:if test="${r"${not empty "}${domainVariable}}">
<input type="hidden" name="id" value="${r"${"}${domainVariable}.id}"/>
</c:if>
<table>
	<#list fieldMappers as fieldMapper>
	<tr>
		<th>${fieldMapper.fieldName}</th>
		<td><input type="text" name="${fieldMapper.fieldName}" value="${r"${"}${domainVariable}.${fieldMapper.fieldName}}"/></td>
	</tr>	
	</#list>		
</table>

<div>
	<c:if test="${r"${empty"} ${domainVariable}}"><input type="button" value="저장" onclick="goInsert()"/></c:if>
	<c:if test="${r"${not empty"} ${domainVariable}}"><input type="button" value="수정" onclick="goUpdate()"/></c:if>
</div>
</form>
